<extend name="layout/main" />

<block name="HEADER">
	<style type="text/css">
		#grid .layui-table-view .layui-table td .layui-table-cell{
			height: 50px;
		    line-height: 50px;
		}
		#grid .file-img {
		    height: 100%;
		    background-position: left;
		    background-size: 100% 85%;
		    background-repeat: no-repeat;
		    cursor: pointer;
		}
	</style>
</block>

<block name="CONTENT">
	<control:grid id="grid"  />
	
	<script id="nameTemplet" type="text/html">
		<div style='line-height:24px;'>
			<p style='overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='{{row.name}}'>
			 	<a href="javascript:void(0);" class="link" on-click="page.edit()">{{row.name}}</a>
			</p>
			<p style='font-size: 13px;color:#e24444;'>
				￥{{row.sale_price}}
				<span style='text-decoration:line-through;color: #a7a7a7;margin-left:10px;'>
					{{row.price}}
				</span>	
			</p>	
		</div>    		
	</script>	
	
	
	<script id="statusTemplet" type="text/html">
		<div style='line-height:26px;font-size:10px;-webkit-transform:scale(0.9);'>
			{{if row.id }} 
				<span style='color:#e24444;padding:0 3px;' class="fl"> 新上 </span>
			{{/if}}
			{{if row.id }} 
				<span style='color:#e24444;padding:0 3px;' class="fl"> 置顶 </span>
			{{/if}}
			{{if row.id }} 
				<span style='color:#e24444;padding:0 3px;' class="fl"> 热销 </span> 
			{{/if}}
			{{if row.id }} 
				<span style='color:#e24444;padding:0 3px;' class="fl"> 精品 </span> 
			{{/if}}
		</div>
	</script>	
	
	<!--驳回-->
	<script id="tpl-reject" type="text/html">
		<form class="layui-form J-changeStatus">
			<table class="xw-table">
				<tr>
					<th width="80"></th><th></th>
					<th width="80"></th><th></th>
				</tr>
				<tr>
					<!--<td class="f-orage"  style="vertical-align: top;">驳回原因</td>-->
					<td colspan="4">
				    	<textarea name="desc" placeholder="请输入驳回原因" class="layui-textarea" datatype="*" style="min-height: 155px;"></textarea>
					</td>
				</tr>
			</table>
		</form>
	</script>	
	
	
	<!--驳回明细-->
	<script id="tpl-reject-detail" type="text/html">
		<form class="layui-form J-changeStatus">
			<table class="xw-table">
				<tr>
					<th width="80"></th><th></th>
					<th width="80"></th><th></th>
				</tr>
				<tr>
					<!--<td class="f-orage"  style="vertical-align: top;">驳回原因</td>-->
					<td colspan="4">
				    	<textarea name="desc" disabled placeholder="请输入驳回原因" class="layui-textarea" datatype="*" style="min-height: 155px;">{{data.status_desc}}</textarea>
					</td>
				</tr>
			</table>
		</form>
	</script>	
	
</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function(ns){
     		
     		//名称模板
		    ns.nameTemplet= function(e){
		    	return  template("nameTemplet",{row:e.data});
		    }
		    
		    //状态模板
		    ns.statusTemplet= function(e){
		    	return  template("statusTemplet",{row:e.data});
		    }
     	
		    //页面初始化
		    ns.init=function(){

		    }
		    
		    //编辑
		    ns.edit = function(id){
		    	var selectedRow = grid.getSelectedRows()[0];
		        var filter = {
		            url: '/modules/goods/goodsList/edit',
		            oid: selectedRow.id ,
		            mode:3,
		           show_comment: id ? 1 : 0
		        }
		        $.openIframe(filter, "编辑",['950px', '92%']);
		    }  
		    
		    //商家信息
		    ns.seeShop = function(shop_id){
		    	var selectedRow = grid.getSelectedRows()[0];
		        var filter = {
		            url:"modules/shop/list/edit",
		            oid: shop_id,
		            mode:3
		        }
		        $.openIframe(filter,"商家信息",['800px', '550px']);
		    }
		    
		    
		    //审批
		    ns.approval = function(){
				var selectedRow = grid.getSelectedRows()[0];
		    	$.confirm("确认审核？", function(index){
		    		grid.updateRow({
		        		'is_apply':1,
		        		'apply_user':__user_name__,
		        		'apply_time':$.getDate("yy-MM-dd HH:mm:ss"),
		        	});
		    		$.toast(1,'成功审核！');
	    			layer.close(index);
		    	});
		    }  
		    
		    
		    //驳回
		    ns.reject = function(){
		    	var selectedRows = grid.getSelectedRows();
			    function yesFn(index){
			        $(".J-changeStatus").validformIn(function(data){ 
			        	grid.updateRow({
			        		'is_apply':'-1',
			        		'apply_desc':data.desc,
			        		'apply_user':__user_name__,
			        		'apply_time':$.getDate("yy-MM-dd HH:mm:ss"),
			        	});
			        	$.toast(1,'已驳回！');
	    				layer.close(index);
			        });
			    }
			    let html= template("tpl-reject",{});
			    $.openModalDialog(html,"驳回",null,yesFn,["400px","250px"]);
		    }  
		    
		    return ns;
		}({}));
		
		
		$(function(){ page.init();  });

	</script>
</block>